<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'controllerNamespace' => 'frontend\controllers',
    'modules' => [
        'attachments' => [
            'class' => 'cza\base\modules\Attachments\Module',
        ],
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
            'class' => 'cza\base\components\web\Request',
            'noCsrfRoutes' => [

            ],
            'cookieValidationKey' => 'DB0uq8cLjtKgh6YYwm4cEZmXEQNrTZav',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
            ]
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        // 'as cors' => [
        //     'class' => \yii\filters\Cors::className(),
        //     'cors' => [
        //         'Origin' => ['http://test.xiuyiwenhua.com'],
        //         'Access-Control-Allow-Credentials' => true,
        //     ],
        // ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                'frontendLog' => [
                    'class' => 'yii\log\FileTarget',
                    'logFile' => "@runtime/logs/" . date('Y-m-d', time()).'.info.log',
                    'categories' => ['application'],
                    'levels' => ['info', 'trace'],
                    // belows setting will keep the log fresh
                    'maxFileSize' => 1024 * 10,
                    'maxLogFiles' => 0,
                ],
                'frontendError' => [
                    'class' => 'yii\log\FileTarget',
                    'logFile' => "@runtime/logs/" . date('Y-m-d', time()).'.error.log',
                    'categories' => ['application'],
                    'levels' => ['error'],
                    // belows setting will keep the log fresh
                    'maxFileSize' => 1024 * 10,
                    'maxLogFiles' => 0,
                ],
                // 'backendError' => [
                //     'class' => 'yii\log\DbTarget',
                //     // 'logFile' => "@runtime/logs/backend_error.log",
                //     'categories' => ['application'],
                //     'levels' => ['error'],
                //     // belows setting will keep the log fresh
                //     // 'maxFileSize' => 0,
                //     // 'maxLogFiles' => 0,
                // ],
                // 'backendSql' => [
                //     'class' => 'yii\log\FileTarget',
                //     'logFile' => "@runtime/logs/backend_sql.log",
                //     'categories' => ['yii\db\*'],
                //     'levels' => ['info'],
                // ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
    ],
    'params' => $params,
];
